package com.shangxian.giveithome.controller;


import com.shangxian.giveithome.entity.AsylumScreen;
import com.shangxian.giveithome.entity.PageableDetails;
import com.shangxian.giveithome.service.AsylumService;
import com.shangxian.giveithome.service.PetFeiService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Component
@RestController
@RequestMapping("/petFei")
public class PetFeiServer {

  @Autowired
  private PetFeiService petFeiService;

  @Autowired
  private AsylumService asylumService;

//  public PageableDetails queryByAsylumById(AsylumScreen asylumScreen, Integer pageNum, Integer pageSize) {
//    return asylumService.queryByMechId(asylumScreen, pageNum, pageSize);
//  }
  @ApiOperation(value = "根据机构id查看收容记录")
  @PostMapping("/queryByAsylumById")
  public PageableDetails queryByAsylumById(@Validated @RequestBody AsylumScreen asylumScreen, @RequestParam("page") Integer pageNum, @RequestParam("size") Integer pageSize) {
    return asylumService.queryByMechId(asylumScreen, pageNum, pageSize);
  }

//  public PageableDetails queryByAdoptionUs(Long id, Pageable pageable) {
//    return petFeiService.queryByUserAdop(id, pageable);
//  }
  @ApiOperation(value = "根据用户id查询已领养信息")
  @GetMapping(value = "/queryFeiAdoptionUs/{id}", name = "根据用户id查询已领养信息")
  public PageableDetails queryByAdoptionUs(@PathVariable Long id, @PageableDefault(page = 0, size = 10) Pageable pageable) {
    return petFeiService.queryByUserAdop(id, pageable);
  }

//  public PageableDetails queryByPlaceUs(Long id, Pageable pageable) {
//    return petFeiService.queryByPlaceUs(id, pageable);
//  }
  @ApiOperation(value = "根据用户id查询已送养-待领养信息")
  @GetMapping(value = "/queryByPlaceUs/{id}", name = "根据用户id查询已送养-待领养信息")
  public PageableDetails queryByPlaceUs(@PathVariable Long id, @PageableDefault(page = 0, size = 10) Pageable pageable) {
    return petFeiService.queryByPlaceUs(id, pageable);
  }

//  public PageableDetails queryByPlaceHistory(Long id, Pageable pageable) {
//    return petFeiService.queryByPlaceHistory(id, pageable);
//  }

  @ApiOperation(value = "根据用户id查询已送养-历史信息")
  @GetMapping(value = "/queryByPlaceHistory/{id}", name = "根据用户id查询已送养-历史信息")
  public PageableDetails queryByPlaceHistory(@PathVariable Long id, @PageableDefault(page = 0, size = 10) Pageable pageable) {
    return petFeiService.queryByPlaceHistory(id, pageable);
  }

//  public PageableDetails searchPeople(Long id, Pageable pageable) {
//    return petFeiService.searchPeople(id, pageable);
//  }

  @ApiOperation(value = "根据用户id查询寻主-寻找中")
  @GetMapping(value = "/searchPeople/{id}", name = "根据用户id查询寻主-寻找中")
  public PageableDetails searchPeople(@PathVariable Long id, Pageable pageable) {
    return petFeiService.searchPeople(id, pageable);
  }

//  public PageableDetails searchPeopleHistory(Long id, Pageable pageable) {
//    return petFeiService.searchPeopleHistory(id, pageable);
//  }

  @ApiOperation(value = "根据用户id查询寻主-历史")
  @GetMapping(value = "/searchPeopleHistory/{id}", name = "根据用户id查询寻主-历史")
  public PageableDetails searchPeopleHistory(@PathVariable Long id, Pageable pageable) {
    return petFeiService.searchPeopleHistory(id, pageable);
  }


//  public PageableDetails searchPet(Long id, Pageable pageable) {
//    return petFeiService.searchPet(id, pageable);
//  }

  @ApiOperation(value = "根据用户id查询寻主-寻找中")
  @GetMapping(value = "/searchPet/{id}", name = "根据用户id查询寻主-寻找中")
  public PageableDetails searchPet(@PathVariable Long id, Pageable pageable) {
    return petFeiService.searchPet(id, pageable);
  }

//  public PageableDetails searchPetHistory(Long id, Pageable pageable) {
//    return petFeiService.searchPetHistory(id, pageable);
//  }

  @ApiOperation(value = "根据用户id查询寻主-历史")
  @GetMapping(value = "/searchPetHistory/{id}", name = "根据用户id查询寻主-历史")
  public PageableDetails searchPetHistory(@PathVariable Long id, Pageable pageable) {
    return petFeiService.searchPetHistory(id, pageable);
  }
}
